<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$merchid=$this->checklogin();
if($_RQ['op']=='list'){
	
	$return['list']['0']['totalprice']=pdo_getsum('jy_weishop_order',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'ispay'=>1,'status >'=>1,'deleted'=>0),'price');
	$return['list']['0']['total']=pdo_count('jy_weishop_order',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid'],'status >'=>1,'ispay'=>1,'deleted'=>0));
	$return['list']['0']['totalmember']=pdo_count('jy_merch_member',array('merchid'=>$merchid,'uniacid'=>$_SESSION['uniacid']));
	$m=pdo_fetchall('select DISTINCT mid,COUNT(1) from '.tablename('jy_weishop_order').' where  uniacid = '.$_SESSION['uniacid'].' and merchid = '.$merchid.' and ispay=1 and deleted=0 group by mid');
    foreach ($m as $key=>$value){
        //$arr2[] = $value["COUNT(1)"];
        $arr2[] = $value["mid"];
    }
	//$return['list']['0']['xfmember']=array_sum($arr2)?array_sum($arr2):0;
	$return['list']['0']['xfmember']=count($arr2)?count($arr2):0;
	if($return['list']['0']['totalmember']>0){
		$return['list']['0']['buy']=price($return['list']['0']['xfmember']/$return['list']['0']['totalmember']*100);		
		$return['list']['0']['xf']=price($return['list']['0']['total']/$return['list']['0']['totalmember']*100);
	}
	$htmls=array(
		'type'=>'list',	
		'list'=>array('data'=>'list','delall'=>false,'del_one'=>false,'edit'=>false,'list'=>array(
			array('name'=>'totalprice','title'=>'订单总金额(已支付)','type'=>'string'),
			array('name'=>'total','title'=>'总订单数(已支付)','type'=>'string'),			
			array('name'=>'totalmember','title'=>'总会员数','type'=>'string'),
			array('name'=>'xfmember','title'=>'消费会员数','type'=>'string'),
			array('name'=>'buy','title'=>'会员消费率(%)','type'=>'string'),
			array('name'=>'xf','title'=>'订单购买率(%)','type'=>'string'),
		)),
		
	);
	$return['htmls']=$htmls;	
	exi($return);
}
